import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/home',
    component: () => import('../views/HomeView.vue')
  },
  {
    path: '/user',
    component: () => import('../views/UserView.vue')
  },
  {
    path: '/sport',
    component: () => import('../views/SportsView.vue')
  },
  {
    path: '/Shop',
    component: () => import('../views/ShopView.vue')
  },
  {
    path: '/comnity',
    component: () => import('../views/CommunityView.vue')
  },
  {
    path: '/login',
    component: () => import('../components/LoginToast.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// 路由导航守卫
router.beforeEach((to, from, next) => {
  // 跳转每一个路由之前都会执行

  // 放行路由
  next()
})

export default router
